#define _CRT_SECURE_NO_WARNINGS 1

class Solution {
public:
    vector<vector<string>> groupAnagrams(vector<string>& strs) {
        unordered_map<string, vector<string>> ans;
        for (string& s : strs)
        {
            string tmp = s;
            sort(tmp.begin(), tmp.end());
            ans[tmp].push_back(s);

        }


        vector<vector<string>> ret;
        ret.reserve(ans.size());
        for (auto& [_, value] : ans)
        {
            ret.push_back(value);
        }
        return ret;
    }

};